﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;

namespace admin
{
    public partial class doing : UserControl
    {
        public doing()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(doing_Loaded);
            this.bt_cancel.Click += new RoutedEventHandler(bt_cancel_Click);
        }

        ServiceReference1.Service1Client sc;

        void doing_Loaded(object sender, RoutedEventArgs e)
        {
            sc = serverManager.getPox();
            sc.loginCompleted += sc_loginCompleted;
            sc.loginAsync(IsolatedStorageSettings.ApplicationSettings["userid"].ToString(),
                IsolatedStorageSettings.ApplicationSettings["pwd"].ToString());
        }

        void sc_loginCompleted(object sender, admin.ServiceReference1.loginCompletedEventArgs e)
        {
            bool sum = (bool)e.Result;
            Page myp = this.Parent as Page;
            if (sum)
            {
                myp.gotopage(new work());
            }
            else
            {
                myp.gotopage(new login());
            }
        }

        void bt_cancel_Click(object sender, RoutedEventArgs e)
        {
            Page myp = this.Parent as Page;
            myp.gotopage(new login());
        }

    }
}
